package com.ntd.frame.gson;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * Gson 工具类
 */
public class GsonUtil {

    public static Gson gsonOfnull = new GsonBuilder().serializeNulls().create();

    public static Gson gson = new Gson();

    public static void main(String[] args) {
        String json = "{\"aDouble\":null}";
        System.out.println(gsonOfnull.fromJson(json, TestNull.class));
        System.out.println(gson.fromJson(json, TestNull.class));
    }

    static class TestNull {
        private Double aDouble;

        @Override
        public String toString() {
            return "TestNull{" +
                "aDouble=" + aDouble +
                '}';
        }
    }
}
